﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DelegatesAndEventsExercise
{
    public class Person
    {
        public enum Gender
        {
            male,
            female
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #region Fields

        private string firstName;
        private string lastName;
        private Gender sex;
        private string birthDate;

        #endregion

        #region Constructors

        public Person(string firstName, string lastName, Gender sex, string birthDate)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.sex = sex;
            this.birthDate = birthDate;
        }

        public Person()
            : this(null, null, Gender.male, null)
        { }

        #endregion

        #region Properties

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                firstName = value;
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                lastName = value;
            }
        }

        public Gender Sex
        {
            get
            {
                return sex;
            }
            set
            {
                sex = value;
            }
        }

        public string BirthDate
        {
            get
            {
                return birthDate;
            }
            set
            {
                birthDate = value;
            }
        }

        #endregion

        protected void OnPropertyChanged(string property, object oldVal, object newVal)
        {
            if (PropertyChanged != null)
            {
                PropertyChangedEventArgs args = new PropertyChangedEventArgs(property, oldVal, newVal);
                PropertyChanged(this, args);
            }
        }

    }
}
